<template>
  <div>
    <el-dialog
      :title="dialogTitle1"
      :visible.sync="dialogVisible1"
      width="98%"
      top="20px"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      append-to-body
    >
      <el-form ref="postForm1" :model="postForm1" class="form-container" label-width="200px" :rules="rules1">
        <el-form-item key="lx" label="类型" prop="lx">
          <el-select v-model="postForm1.lx" placeholder="请选择" clearable style="width: 200px" class="filter-item">
            <el-option v-for="(it,index) in lxList" :key="index" :label="it.label" :value="it.value" />
          </el-select>
        </el-form-item>
        <div />
        <el-form-item v-if="postForm1.lx==='0201'" key="zb" prop="zb" label="占比">
          <el-input-number v-model="postForm1.zb" style="width:200px" /> %
        </el-form-item>
        <el-form-item v-if="postForm1.lx==='0202'" key="pp" prop="pp" label="品牌">
          <el-input v-model="postForm1.pp" style="width:200px" />
        </el-form-item>
        <el-form-item v-if="postForm1.lx==='0202'" key="cph" prop="cph" label="车牌号">
          <el-input v-model="postForm1.cph" style="width:200px" />
        </el-form-item>
        <el-form-item v-if="postForm1.lx==='0203'||postForm1.lx==='0204'" key="dz" prop="dz" label="地址">
          <el-input v-model="postForm1.dz" style="width:400px" />
        </el-form-item>
        <el-form-item v-if="postForm1.lx==='0203'||postForm1.lx==='0204'" key="mj" prop="mj" label="面积">
          <el-input-number v-model="postForm1.mj" style="width:200px" /> 平米
        </el-form-item>
        <el-form-item v-if="postForm1.lx==='0205'||postForm1.lx==='0206'||postForm1.lx==='0207'" key="xq" prop="xq" label="详情">
          <el-input v-model="postForm1.xq" style="width:400px" />
        </el-form-item>
        <div />
        <el-form-item key="zt" label="状态" prop="zt">
          <el-select v-model="postForm1.zt" placeholder="请选择" clearable style="width: 200px" class="filter-item">
            <el-option label="无" :value="null" />
            <el-option v-for="(it,index) in ztList" :key="index" :label="it.label" :value="it.value" />
          </el-select>
        </el-form-item>
        <el-form-item key="sm" label="说明" prop="sm">
          <el-input v-model="postForm1.sm" type="textarea" style="width:400px" />
        </el-form-item>
        <div />
        <el-form-item key="submit" style="margin:10px 0 0 200px">
          <el-button type="primary" :loading="loading" @click="submitForm1">保存</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <el-dialog
      :title="dialogTitle2"
      :visible.sync="dialogVisible2"
      width="98%"
      top="20px"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      append-to-body
    >
      <el-form ref="postForm2" :model="postForm2" class="form-container" label-width="200px" :rules="rules2">
        <el-form-item label="姓名" prop="name">
          <el-input v-model="postForm2.name" style="width:200px" />
        </el-form-item>
        <el-form-item label="年龄" prop="age">
          <el-input-number v-model="postForm2.age" style="width:200px" />
        </el-form-item>
        <el-form-item label="性别" prop="sex">
          <el-radio-group v-model="postForm2.sex">
            <el-radio label="男" />
            <el-radio label="女" />
          </el-radio-group>
        </el-form-item>
        <el-form-item label="身份证号" prop="idcard">
          <el-input v-model="postForm2.idcard" style="width:200px" />
        </el-form-item>
        <el-form-item label="家庭住址" prop="address">
          <el-input v-model="postForm2.address" style="width:600px" />
        </el-form-item>
        <el-form-item label="户籍所在地" prop="hjszd">
          <el-input v-model="postForm2.hjszd" style="width:600px" />
        </el-form-item>
        <el-form-item label="强制措施日期" prop="qzdate">
          <el-date-picker v-model="postForm2.qzdate" type="date" value-format="yyyy-MM-dd" placeholder="请选择" style="width:200px" />
        </el-form-item>
        <el-form-item label="强制措施种类" prop="qztype">
          <el-select v-model="postForm2.qztype" placeholder="请选择" clearable style="width: 200px" class="filter-item">
            <el-option label="无" :value="null" />
            <el-option v-for="(it,index) in qztypeList" :key="index" :label="it.label" :value="it.value" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" :loading="loading" @click="submitForm2">保存</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <el-dialog
      :title="fileDialogTitle"
      :visible.sync="fileDialogVisible"
      width="98%"
      top="20px"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      append-to-body
    >
      <el-form ref="filePostForm" :model="filePostForm" class="form-container" label-width="200px" :rules="fileRules">
        <el-form-item v-if="!readOnly" label="文件" prop="file">
          <el-upload
            class="upload-demo"
            :action="this.$http.defaults.baseURL+'api/gen/file/upload/'"
            :on-success="handleUploadSucc"
            :on-remove="handleRemove"
            :before-remove="beforeRemove"
            :on-error="uploadError"
            :multiple="true"
            :file-list="fileList"
            :headers="myHeaders"
            :on-preview="handlePreview"
          >
            <el-button type="primary">点击上传</el-button>
          </el-upload>
        </el-form-item>
        <el-form-item label="说明" prop="address">
          <el-input v-model="filePostForm.remark" type="textarea" style="width:800px" rows="10" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" :loading="loading" @click="submitFileForm">保存</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <el-form ref="postForm" :model="postForm" :rules="rules" class="form-container" label-width="200px" :inline="true">
      <el-form-item label="处非案件编号" prop="cfajbh">
        {{ postForm.id?postForm.cfajbh:'自动生成' }}
      </el-form-item>
      <el-form-item label="案件号" prop="ajh">
        <el-input v-model="postForm.ajh" style="width:200px" />
      </el-form-item>
      <div />
      <el-form-item label="案件名称" prop="ajmc">
        <el-input v-model="postForm.ajmc" style="width:400px" />
      </el-form-item>
      <div />
      <el-form-item label="法人" prop="fr">
        <el-input v-model="postForm.fr" style="width:200px" />
      </el-form-item>
      <el-form-item label="实际控股人" prop="sjkzr">
        <el-input v-model="postForm.sjkzr" style="width:200px" />
      </el-form-item>
      <div />
      <el-form-item label="涉及金额（万元）" prop="sjje">
        <el-input-number v-model="postForm.sjje" />
      </el-form-item>
      <el-form-item label="未兑付金额（万元）" prop="wdfje">
        <el-input-number v-model="postForm.wdfje" />
      </el-form-item>
      <div />
      <el-form-item label="集资人数" prop="jzrs">
        <el-input-number v-model="postForm.jzrs" />
      </el-form-item>
      <div />
      <el-form-item label="立案时间" prop="lasj">
        <el-date-picker v-model="postForm.lasj" style="width:200px" value-format="yyyy-MM-dd" />
      </el-form-item>
      <div />
      <el-form-item label="办案单位" prop="badw">
        <el-input v-model="postForm.badw" style="width:400px" />
      </el-form-item>
      <el-form-item label="办案负责人" prop="bafzr">
        <el-input v-model="postForm.bafzr" style="width:200px" />
      </el-form-item>
      <div />
      <el-form-item label="案件简述" prop="ajjs">
        <el-input v-model="postForm.ajjs" type="textarea" style="width:810px" />
      </el-form-item>
      <div />
      <div v-show="showmore">
        <h3>查扣资产情况</h3>
        <el-table
          ref="processTable"
          :data="zcqkList"
          border
          fit
          highlight-current-row
          style="width: 100%;margin-bottom:20px;"
        >
          <el-table-column align="center" prop="lx" label="类型" width="100">
            <template slot-scope="scope">
              {{ lxText(scope.row.lx) }}
            </template>
          </el-table-column>
          <el-table-column prop="content" label="详情" min-width="250" align="left">
            <template slot-scope="scope">
              {{ xqText(scope.row) }}
            </template>
          </el-table-column>
          <el-table-column align="center" prop="zt" label="状态" width="100">
            <template slot-scope="scope">
              {{ ztText(scope.row.zt) }}
            </template>
          </el-table-column>
          <el-table-column align="center" prop="sm" label="说明备注" width="200" />
          <el-table-column width="200">
            <template slot="header">
              <el-button
                type="success"
                @click="add1"
              >新增</el-button>
            </template>
            <template slot-scope="scope">
              <el-button
                type="primary"
                @click="handleEdit(scope.$index, scope.row)"
              >修改</el-button>
              <el-popconfirm title="确定删除该信息吗？" style="margin-left:10px;" @onConfirm="handleDelete(scope.$index)">
                <el-button slot="reference" type="danger">删除</el-button>
              </el-popconfirm>
            </template>
          </el-table-column>
        </el-table>
        <h3>嫌疑人羁押、管控情况</h3>
        <el-table
          ref="processTable"
          :data="gkqkList"
          border
          fit
          highlight-current-row
          style="width: 100%;margin-bottom:20px;"
        >
          <el-table-column prop="xm" label="姓名" width="100" align="center" />
          <el-table-column prop="nl" label="年龄" width="60" align="center" />
          <el-table-column prop="xb" label="性别" width="60" align="center" />
          <el-table-column prop="sfzh" label="身份证号" width="220" align="center" />
          <el-table-column prop="jtzz" label="家庭住址" min-width="250" align="center" />
          <el-table-column prop="hjszd" label="户籍所在地" width="150" align="center" />
          <el-table-column prop="qzcsrq" label="强制措施日期" width="150" align="center" />
          <el-table-column prop="qzcszl" label="强制措施种类" width="200" align="center">
            <template slot-scope="scope">
              {{ qztypeText(scope.row.qzcszl) }}
            </template>
          </el-table-column>
          <el-table-column width="200">
            <template slot="header">
              <el-button
                type="success"
                @click="add2"
              >新增</el-button>
            </template>
            <template slot-scope="scope">
              <el-button
                type="primary"
                @click="handleEdit2(scope.$index, scope.row)"
              >修改</el-button>
              <el-popconfirm title="确定删除该信息吗？" style="margin-left:10px;" @onConfirm="handleDelete2(scope.$index)">
                <el-button slot="reference" type="danger">删除</el-button>
              </el-popconfirm>
            </template>
          </el-table-column>
        </el-table>
        <h3>附件</h3>
        <el-table
          ref="processTable"
          :data="fjList"
          border
          fit
          highlight-current-row
          style="width: 100%;margin-bottom:20px;"
        >
          <el-table-column prop="fileName" label="文件名" width="300" align="center" />
          <el-table-column prop="dataCreateDatetime" label="上传时间" width="100" align="center" />
          <el-table-column prop="remark" label="内容" min-width="400" align="center" />
          <el-table-column width="200">
            <template slot="header">
              <el-button
                type="success"
                @click="addFile"
              >新增</el-button>
            </template>
            <template slot-scope="scope">
              <el-popconfirm title="确定删除该信息吗？" style="margin-left:10px;" @onConfirm="handleDelete2(scope.$index)">
                <el-button slot="reference" type="danger">删除</el-button>
              </el-popconfirm>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-form-item style="margin:10px 0 0 200px">
        <el-button type="primary" :loading="loading" @click="submitForm">保存</el-button>
        <el-switch
          v-model="showmore"
          active-color="#13ce66"
          inactive-color="#ff4949"
          style="margin:0 10px 0 20px;"
        />{{ showmore?'隐藏更多':'显示更多' }}
      </el-form-item>
      <h2>督办情况</h2>
      <el-table
        ref="processTable"
        :data="processList"
        border
        fit
        highlight-current-row
        style="width: 100%"
      >
        <el-table-column align="center" prop="time" label="次数" width="100" />
        <el-table-column align="center" prop="unit1" label="督办单位" width="150" />
        <el-table-column align="center" prop="unit2" label="被督办单位" width="150" />
        <el-table-column align="center" prop="date" label="督办时间" width="100" />
        <el-table-column align="center" prop="limit" label="督办期限" width="100" />
        <el-table-column align="center" prop="item" label="督办事项" min-width="200" show-overflow-tooltip />
        <el-table-column align="center" prop="result" label="办理结果" min-width="200" show-overflow-tooltip />
        <el-table-column>
          <template slot="header">
            <el-button
              type="success"
              @click="handleEdit(scope.$index, scope.row)"
            >新增</el-button>
          </template>
          <template slot-scope="scope">
            <el-button
              type="primary"
              @click="handleEdit(scope.$index, scope.row)"
            >修改</el-button>
            <el-button
              type="danger"
              @click="handleDelete(scope.$index, scope.row)"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-form>

  </div>
</template>

<script>

const defaultForm = {
  ajh: '',
  ajmc: '',
  fr: '',
  sjkzr: '',
  sjje: '',
  wdfje: '',
  jzrs: '',
  lasj: '',
  badw: '',
  bafzr: '',
  ajjs: '',
  id: null
}
const defaultForm1 = {
  lx: '',
  zb: 0,
  dz: '',
  mj: 0,
  pp: '',
  cph: '',
  xq: '',
  zt: '',
  sm: ''
}
const defaultForm2 = {
  name: '',
  age: '',
  sex: '',
  idcard: '',
  address: '',
  hjszd: '',
  qzdate: '',
  qztype: ''
}
const defaultFileForm = {
  fileid: 0,
  remark: ''
}
export default {
  name: 'ArticleDetail',
  props: {
    readOnly: {
      type: Boolean,
      default: false
    },
    infoid: {
      type: Number,
      default: 0
    },
    timestamp: {
      type: Number,
      default: 0
    },
    step: {
      type: String,
      default: ''
    }
  },
  data() {
    const validateRequire = (rule, value, callback) => {
      if (value === '') {
        // this.$message({
        //   message: '请将表单填写完整',
        //   type: 'error'
        // })
        callback(new Error('必填项'))
      } else {
        callback()
      }
    }
    return {
      showmore: false,
      xyrindex: -1,
      zcindex: -1,
      ztList: [],
      lxList: [],
      zlList: [],
      fjlList: [],
      fjList: [],
      qztypeList: [],
      dialogVisible1: false,
      dialogTitle1: '新增',
      dialogVisible2: false,
      dialogTitle2: '新增',
      fileDialogVisible: false,
      fileDialogTitle: '新增',
      zcqkList: [
        // { type: '股权', content: '占比：50%' },
        // { type: '车辆', content: '品牌：奔驰S300 车牌号：冀RXXXXX', state: '查封手续', remarks: '' },
        // { type: '房产', content: '广阳区某某小区1-1-101 面积：130.11平米', state: '查封', remarks: '' },
        // { type: '土地', content: '广阳区某某乡某某村 面积：10000平米', state: '未查封', remarks: '' },
        // { type: '贵金属', content: '黄金5000g', state: '', remarks: '' },
        // { type: '办公用品', content: '惠普打印机S111一台', state: '', remarks: '' }
      ],
      gkqkList: [
        // { name: '张三', age: '40', sex: '男', idcard: '131002198001011234', address: '广阳区某某小区1-1-101', hjszd: '河北省廊坊市', qzdate: '2021-05-01', qztype: '拘留' }
      ],
      myid: 0,
      roleName: '',
      deptName: '',
      realName: '',
      myHeaders: {},
      imageUrl: '',
      infoLoading: false,
      postForm: Object.assign({}, defaultForm),
      postForm1: Object.assign({}, defaultForm1),
      postForm2: Object.assign({}, defaultForm2),
      filePostForm: Object.assign({}, defaultFileForm),
      loading: false,
      deptOption: [],
      userOption: [],
      processUserOption: [],
      priorityOption: [],
      classCodeOption: [],
      flowTypeOption: [],
      rules: {
        ajh: [{ validator: validateRequire }],
        ajmc: [{ validator: validateRequire }],
        fr: [{ validator: validateRequire }],
        sjkzr: [{ validator: validateRequire }],
        sjje: [{ validator: validateRequire }],
        wdfje: [{ validator: validateRequire }],
        jzrs: [{ validator: validateRequire }],
        lasj: [{ validator: validateRequire }],
        badw: [{ validator: validateRequire }],
        bafzr: [{ validator: validateRequire }],
        ajjs: [{ validator: validateRequire }]
      },
      rules1: {
        lx: [{ validator: validateRequire }],
        zb: [{ validator: validateRequire }],
        pp: [{ validator: validateRequire }],
        cph: [{ validator: validateRequire }],
        mj: [{ validator: validateRequire }],
        dz: [{ validator: validateRequire }],
        xq: [{ validator: validateRequire }]
      },
      rules2: {
        name: [{ validator: validateRequire }],
        sex: [{ validator: validateRequire }],
        age: [{ validator: validateRequire }],
        idcard: [{ validator: validateRequire }],
        address: [{ validator: validateRequire }],
        hjszd: [{ validator: validateRequire }]
      },
      rules3: {
        completed: [{ validator: validateRequire }]
      },
      rules4: {
        passed: [{ validator: validateRequire }]
      },
      rules5: {
        evaluateResult: [{ validator: validateRequire }]
      },
      tempRoute: {},
      processListLoading: false,
      processList: [{ time: '第一次', unit1: '处非办', unit2: '公安局', date: '2021-05-10', limit: '10天', item: '尽快办理', result: '已办结' }, { time: '第二次', unit1: '处非办', unit2: '公安局', date: '2021-05-20', limit: '10天', item: '尽快办理', result: '已办结' }],
      processNow: {},
      mystep: ''
    }
  },
  watch: {
    timestamp: {
      handler(val, oldVal) {
        this.mystep = this.step
        this.myid = this.infoid
        this.getData(this.myid)
      },
      immediate: true
    }
  },
  mounted() {
    this.myHeaders = {
      Authorization: 'Bearer ' + localStorage.getItem('token')
    }
    this.getOptions()
    const day = new Date()
    day.setTime(day.getTime())
    console.log(JSON.parse(localStorage.getItem('user')))
    this.roleName = JSON.parse(localStorage.getItem('user')).roleName
    // this.postForm.publishTime = day.getFullYear() + '-' + this.add0(day.getMonth() + 1) + '-' + this.add0(day.getDate())
  },
  created() {
    this.tempRoute = Object.assign({}, this.$route)
  },
  methods: {
    handleDelete(index) {
      this.zcqkList.splice(index, 1)
    },
    handleDelete2(index) {
      this.gkqkList.splice(index, 1)
    },
    qztypeText(val) {
      if (this.qztypeList.find(item => item.value === val)) {
        return this.qztypeList.find(item => item.value === val).label
      } else {
        return ''
      }
    },
    ztText(val) {
      if (this.ztList.find(item => item.value === val)) {
        return this.ztList.find(item => item.value === val).label
      } else {
        return ''
      }
    },
    lxText(val) {
      if (this.lxList.find(item => item.value === val)) {
        return this.lxList.find(item => item.value === val).label
      } else {
        return ''
      }
    },
    xqText(row) {
      switch (row.lx) {
        case '0201':
          return '占比：' + row.zb + '%'
        case '0202':
          return '品牌：' + row.pp + '，车牌号：' + row.cph
        case '0203':
        case '0204':
          return '地址：' + row.dz + '，面积：' + row.mj + '平米'
        default:
          return row.xq
      }
    },
    submitForm1() {
      this.$refs.postForm1.validate(valid => {
        if (valid) {
          let item = {}
          switch (this.postForm1.lx) {
            case '0201':
              item = { 'lx': this.postForm1.lx, 'zb': this.postForm1.zb, 'zt': this.postForm1.zt, 'sm': this.postForm1.sm }
              break
            case '0202':
              item = { 'lx': this.postForm1.lx, 'pp': this.postForm1.pp, 'cph': this.postForm1.cph, 'zt': this.postForm1.zt, 'sm': this.postForm1.sm }
              break
            case '0203':
            case '0204':
              item = { 'lx': this.postForm1.lx, 'dz': this.postForm1.dz, 'mj': this.postForm1.mj, 'zt': this.postForm1.zt, 'sm': this.postForm1.sm }
              break
            default:
              item = { 'lx': this.postForm1.lx, 'xq': this.postForm1.xq, 'zt': this.postForm1.zt, 'sm': this.postForm1.sm }
              break
          }
          if (this.zcindex === -1) {
            this.zcqkList.push(item)
          } else {
            this.zcqkList[this.zcindex] = item
          }
          this.dialogVisible1 = false
          this.$message({
            message: '保存成功',
            type: 'success'
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    submitForm2() {
      this.$refs.postForm2.validate(valid => {
        if (valid) {
          const item = { 'xm': this.postForm2.name, 'nl': this.postForm2.age, 'xb': this.postForm2.sex, 'sfzh': this.postForm2.idcard, 'jtzz': this.postForm2.address, 'hjszd': this.postForm2.hjszd, 'qzcsrq': this.postForm2.qzdate, 'qzcszl': this.postForm2.qztype }
          if (this.xyrindex === -1) {
            this.gkqkList.push(item)
          } else {
            console.log(item)
            console.log(this.xyrindex)
            this.gkqkList[this.xyrindex] = item
          }
          this.dialogVisible2 = false
          this.$message({
            message: '保存成功',
            type: 'success'
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    submitFileForm() {},
    handleEdit(index, item) {
      this.postForm1 = item
      this.zcindex = index
      this.dialogVisible1 = true
      this.dialogTitle1 = '修改'
    },
    handleEdit2(index, item) {
      this.postForm2.name = item.xm
      this.postForm2.age = item.nl
      this.postForm2.sex = item.xb
      this.postForm2.idcard = item.sfzh
      this.postForm2.qzdate = item.qzcsrq
      this.postForm2.qztype = item.qzcszl
      this.postForm2.address = item.jtzz
      this.postForm2.hjszd = item.hjszd
      this.xyrindex = index
      this.dialogVisible2 = true
      this.dialogTitle2 = '修改'
    },
    add1() {
      this.zcindex = -1
      this.postForm1 = Object.assign({}, defaultForm1)
      this.dialogVisible1 = true
      this.dialogTitle1 = '新增'
    },
    add2() {
      this.xyrindex = -1
      this.postForm2 = Object.assign({}, defaultForm2)
      this.dialogVisible2 = true
      this.dialogTitle2 = '新增'
    },
    addFile() {
      this.filePostFormForm = Object.assign({}, defaultFileForm)
      this.fileDialogVisible = true
      this.fileDialogTitle = '新增'
    },
    handleAvatarSuccess(res, file) {
      // this.imageUrl = URL.createObjectURL(file.raw)
      console.log('test')
      if (res.success) {
        this.$message({
          message: '上传成功！',
          type: 'success'
        })
        this.imageUrl = res.result[0].id
        // this.fileList = []
        // this.files = []
      } else {
        this.$message({
          message: '上传失败:' + res.message,
          type: 'error'
        })
      }
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === 'image/jpeg'
      const isPNG = file.type === 'image/png'
      const isGIF = file.type === 'image/gif'
      const isLt20M = file.size / 1024 / 1024 < 20

      if (!isJPG && !isPNG && !isGIF) {
        this.$message.error('上传图片只能是 JPG 或 PNG 格式!')
        return false
      }
      if (!isLt20M) {
        this.$message.error('上传图片大小不能超过 20MB!')
        return false
      }
    },
    getData(id) {
      this.infoLoading = true
      if (id) {
        this.$http
          .get('/api/ga/getGaById?&id=' + id)
          .then(response => {
            this.infoLoading = false
            if (response.data.success === true) {
              this.postForm = response.data.result
              this.gkqkList = response.data.result.gkqkList
              this.zcqkList = response.data.result.zcqkList
            } else {
              console.log('获取失败:' + response.data.message)
              this.$message({
                message: '获取失败:' + response.data.message,
                type: 'error'
              })
            }
          })
          .catch(error => {
            console.log(error)
            this.infoLoading = false
          })
      } else {
        this.$nextTick(() => {
          this.infoLoading = false
          this.postForm = Object.assign({}, defaultForm)
          this.zcqkList = []
          this.gkqkList = []
        })
      }
    },
    getOptions() {
      let code = '01'
      this.$http
        .get('/api/sysDict/getByCode?enabled=true&code=' + code)
        .then(response => {
          if (response.data.success === true) {
            this.ztList = response.data.result
          } else {
            console.log('获取失败:' + response.data.message)
            this.$message({
              message: '获取失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          console.log(error)
        })
      code = '02'
      this.$http
        .get('/api/sysDict/getByCode?enabled=true&code=' + code)
        .then(response => {
          if (response.data.success === true) {
            this.lxList = response.data.result
          } else {
            console.log('获取失败:' + response.data.message)
            this.$message({
              message: '获取失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          console.log(error)
        })
      code = '03'
      this.$http
        .get('/api/sysDict/getByCode?enabled=true&code=' + code)
        .then(response => {
          if (response.data.success === true) {
            this.qztypeList = response.data.result
          } else {
            console.log('获取失败:' + response.data.message)
            this.$message({
              message: '获取失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          console.log(error)
        })
    },
    submitForm() {
      this.$refs.postForm.validate(valid => {
        if (valid) {
          const para = {
            id: this.postForm.id ? this.postForm.id : null,
            ajh: this.postForm.ajh,
            ajmc: this.postForm.ajmc,
            fr: this.postForm.fr,
            sjkzr: this.postForm.sjkzr,
            sjje: this.postForm.sjje,
            wdfje: this.postForm.wdfje,
            jzrs: this.postForm.jzrs,
            lasj: this.postForm.lasj,
            badw: this.postForm.badw,
            bafzr: this.postForm.bafzr,
            ajjs: this.postForm.ajjs,
            gkqkList: this.gkqkList,
            zcqkList: this.zcqkList
          }
          this.loading = true
          this.$http
            .post('/api/ga/saveGa', para)
            .then(response => {
              this.loading = false
              if (response.data.success === true) {
                this.$message({
                  message: '保存成功',
                  type: 'success'
                })
                this.$emit('dialogHide')
                this.postForm = Object.assign({}, defaultForm)
                this.loading = false
              } else {
                console.log('保存失败:' + response.data.message)
                this.$message({
                  message: '保存失败:' + response.data.message,
                  type: 'error'
                })
              }
            })
            .catch(function(error) {
              console.log(error)
              this.loading = false
            })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
